<style>
@media print{
	#hide{
		display:none;
	}
}
#hide{
	width: 150px;
	height:30px; 
}
</style>
<center>
<input type="button" value="Return To Portal" id="hide" onClick="window.location = 'http://192.168.120.9/techcenter/Hardware_Software_Center.php'"> <input type="button" value="Print Receipt" id="hide" onClick="window.print() ">
</center>
<?php
include_once($_SERVER['DOCUMENT_ROOT'].'/includes/config.inc.php');
include_once("config.php");
getConfig();
checkActiveLogin();
getUserInfo();
$hardware = false;
$software = false;
foreach ($_SESSION['items'] as $value) {
	$sql = "SELECT * FROM `tbHardware` WHERE `iItemID` = :id ORDER BY `sMain` DESC";
	$q = db::Query($sql, array(':id'=>$value));
	$row2 = $q->fetch();
	if($row2['iItemID'] != $value){
		$software = true;
	}else{
		$hardware = true;
	}
}
if($hardware){
$cont = false;
while($cont == false){
	$abc= array("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z");
	$receiptid = rand(11111, 99999)."-".strtoupper($abc[rand(0,25)]).rand(11,99);
	$sql = "SELECT * FROM `tbLoanReceipts`";
	$q = db::Query($sql);
	$good = true;
	while($row = $q->fetch()){
		if($row['sReceiptId'] == $receiptid){
			$good = false;
		}
	}
	if($good){
		$cont = true;
	}
}
$duedate =  strtotime($_POST['due']);
$sql = "SELECT * FROM SPRIDEN, GOBTPAC WHERE SPRIDEN_PIDM = GOBTPAC_PIDM AND SPRIDEN_ID = :uname AND SPRIDEN_CHANGE_IND is null";
$q = Oracle::Query($sql, array(':uname'=>$_POST['banner']));
$row = $q->fetch();


	
$sql = "INSERT INTO `tbLoanReceipts` (`sReceiptId`, `sFname`, `sLname`, `sBannerId`, `sEmail`, `sPhone`, `sDepartment`, `sType`, `sDate`, `sTime`, `sUname`, `sStatus`, `sDue`, `sPurpose`) VALUES (:id, :fname, :lname, :bid, :email, :phone, :department, :type, :date, :time, :uname, :status, :due, :purpose);";

db::Query($sql, array(':id'=>$receiptid, ':fname'=>$row['SPRIDEN_FIRST_NAME'], ':lname'=>$row['SPRIDEN_LAST_NAME'], ':bid'=>$_POST['banner'], ':email'=>$row['GOBTPAC_EXTERNAL_USER']."@edison.edu", ':phone'=>$_POST['number'], ':department'=>$_POST['department'], ':type'=>'Hardware', ':date'=>getCurrentDate(), ':time'=>getCurrentTime(), ':uname'=>$USER['sUname'], ':status'=>'Awaiting Return', ':due'=>$duedate, ':purpose'=>$_POST['purpose']));
?>
<title>Edison State College Loan Receipt</title>
<body>
<div style="position:absolute; top:10; right:20; text-align:center; font-weight:bold; font-size:18px">
Receipt ID:<br/>
<?php echo $receiptid ?>
</div>
<b>
    <center>
        Edison State College<br />
        College Administrative Procedures<br />
        Division of Technology Services<br />
        <br />
        Technology Services Division Equipment Loan Program
    </center>
    <hr />
    <br>
    <br>
    <table>
        <tr>
            <td style="border-bottom:solid; border-bottom-width:1px" width="500px"><?php echo $row['SPRIDEN_FIRST_NAME']." ".$row['SPRIDEN_LAST_NAME'] ?></td>
            <td width="30px">&nbsp;</td>
            <td style="border-bottom:solid; border-bottom-width:1px" width="500px"><?php echo $_POST['department'] ?></td>
        </tr>
        <tr>
            <td><b>&nbsp;&nbsp;&nbsp;Requestor's Name</b></td>
            <td width="30px">&nbsp;</td>
            <td><b>&nbsp;&nbsp;&nbsp;Department/Divison - Campus</b></td>
        </tr>
        <tr>
            <td colspan="3">&nbsp;</td>
        </tr>
        <tr>
            <td style="border-bottom:solid; border-bottom-width:1px" width="500px"><?php echo $_POST['number'] ?></td>
            <td width="30px">&nbsp;</td>
            <td style="border-bottom:solid; border-bottom-width:1px" width="500px"><?php echo date("F d, Y") ?></td>
        </tr>
        <tr>
            <td><b>&nbsp;&nbsp;&nbsp;Office Phone Number</b></td>
            <td width="30px">&nbsp;</td>
            <td><b>&nbsp;&nbsp;&nbsp;Equipment Check-Out Date</b></td>
        </tr>
        <tr>
            <td colspan="3">&nbsp;</td>
        </tr>
        <tr>
            <td style="border-bottom:solid; border-bottom-width:1px" width="500px">&nbsp;</td>
            <td width="30px">&nbsp;</td>
            <td style="border-bottom:solid; border-bottom-width:1px" width="500px"><?php echo date("F d, Y", strtotime($_POST['return'])) ?></td>
        </tr>
        <tr>
            <td><b>&nbsp;&nbsp;&nbsp;Director or VP Approval</b></td>
            <td width="30px">&nbsp;</td>
            <td><b>&nbsp;&nbsp;&nbsp;Equipment Return Date</b></td>
        </tr>
        <tr>
            <td colspan="3">&nbsp;</td>
        </tr>
        <tr>
            <td style="border-bottom:solid; border-bottom-width:1px" colspan="3"><b>Academic/Business Purpose:</b> <?php echo $_POST['purpose'] ?></td>
        </tr>
    </table>
    <br />
    <table width="100%" cellpadding="0" cellspacing="0">
        <tr>
            <td><b>&nbsp;&nbsp;&nbsp;Equipment Issued</b></td>
            <td width="100px" style="border:solid; border-width:1px; padding-top:5px; padding-bottom:5px; padding-left:5px;">&#8730; = Issued</td>
            <td width="100px" style="border:solid; border-width:1px; padding-top:5px; padding-bottom:5px; padding-left:5px;">&#8730; = Returned</td>
        </tr>
            <?php					
            foreach ($_SESSION['items'] as $value) {
				$sql = "SELECT * FROM `tbHardware` WHERE `iItemID` = :id ORDER BY `sMain` DESC";
				$q = db::Query($sql, array(':id'=>$value));
				$row2 = $q->fetch();
				if($row2['iItemID'] != $value){
					$software = true;
				}else{
					$q = db::Query($sql, array(':id'=>$value));
					$sql = "INSERT INTO `tbLoanLink` (`sReceiptId`, `sItem`, `sItemIdentifier`) VALUES (:id,:item,:identifier);";
					while($row2 = $q->fetch()){
						db::Query($sql, array(':id'=>$receiptid, ':item'=>$row2['sDescription'], ':identitifer'=>$row2['iItemID']));
                    ?>
        <tr>
            <td style="border:solid; border-width:1px; padding-top:5px; padding-bottom:5px; padding-left:5px;"><?php echo $row2['sDescription'] ?></td>
            <td width="100px" align="center" style="border:solid; border-width:1px;">&#8730;</td>
            <td width="100px" style="border:solid; border-width:1px;">&nbsp;</td>
        </tr>
                    <?php };
            	}; 
			} ?>
    </table><br />
    I have read the Technology Services Division Equipment Loan Program Procedure.  By signing below, I certify that the equipment indicated above was checked-out/checked-in as indicated and hereby agree to abide be the terms stated in the Technology Services Division Equipment Loan Program Procedure and will provide proper care according to the guidelines.  I understand that the department of the signed employee is assuming financial reponibility for the equipment.
    <table>
        <tr>
            <td><br />
                <b>CHECK-OUT:</b><br><br>
                ___________________________<br>
                Date Checked Out<br><br>
                ___________________________<br>
                <?php echo $row['SPRIDEN_FIRST_NAME']." ".$row['SPRIDEN_LAST_NAME'] ?><br><br>
            ___________________________<br>
            <?php echo $USER['sFname']." ".$USER['sLname'] ?> - Tech Center SA
        </td>
        <td width="90">
        </td>
        <td>
            <b>CHECK-IN:</b><br><br>
            ___________________________<br>
            Date Checked In<br><br>
            ___________________________<br>
            Incoming Tech Center SA
        </td>
        </tr>
    </table>
<?php } ?>
<?php
if($software){
	foreach ($_SESSION['items'] as $value) {
	$sql = "SELECT * FROM `tbHardware` WHERE `iItemID` = :id ORDER BY `sMain` DESC";
	$q = db::Query($sql, array(':id'=>$value));
	$row2 = $q->fetch();
	if($row2['iItemID'] != $value){
		$software = true;
		$sql = "SELECT * FROM `tbSoftware` WHERE `iItemID` = :id";
		$q = db::Query($sql, array(':id'=>$value));
		$row23 = $q->fetch();
		$cont = false;
		while($cont == false){
			$abc= array("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z");
			$receiptid = rand(11111, 99999)."-".strtoupper($abc[rand(0,25)]).rand(11,99);
			$sql = "SELECT * FROM `tbLoanReceipts`";
			$q = mysql_query($sql);
			$good = true;
			while($row2 = mysql_fetch_assoc($q)){
				if($row2['sReceiptId'] == $receiptid){
					$good = false;
				}
			}
			if($good){
				$cont = true;
			}
		}
$duedate =  strtotime('+3 days');

$sql = "SELECT * FROM SPRIDEN, GOBTPAC WHERE SPRIDEN_PIDM = GOBTPAC_PIDM AND SPRIDEN_ID = :uname AND SPRIDEN_CHANGE_IND is null";
$q = Oracle::Query($sql, array(':uname'=>$_POST['banner']));
$row = $q->fetch();

$sql = "INSERT INTO `tbLoanReceipts` (`sReceiptId`, `sFname`, `sLname`, `sBannerId`, `sEmail`, `sPhone`, `sDepartment`, `sType`, `sDate`, `sTime`, `sUname`, `sStatus`, `sDue`, `sPurpose`) VALUES (:id, :fname, :lname, :bid, :email, :phone, :department, :type, :date, :time, :uname, :status, :due, :purpose);";

db::Query($sql, array(':id'=>$receiptid, ':fname'=>$row['SPRIDEN_FIRST_NAME'], ':lname'=>$row['SPRIDEN_LAST_NAME'], ':bid'=>$_POST['banner'], ':email'=>$row['GOBTPAC_EXTERNAL_USER']."@edison.edu", ':phone'=>$_POST['number'], ':department'=>$_POST['department'], ':type'=>'Software', ':date'=>getCurrentDate(), ':time'=>getCurrentTime(), ':uname'=>$USER['sUname'], ':status'=>'Awaiting Return', ':due'=>$duedate, ':purpose'=>$_POST['purpose']));

$sql = "INSERT INTO `tbLoanLink` (`sReceiptId`, `sItem`, `sItemIdentifier`) VALUES (:rec,:item,:identifier);";
db::Query($sql, array(':rec'=>$receiptid, ':item'=>$row23['sDescription'], ':identifier'=>$row23['iItemID']));
?>
<div style="page-break-before:always; position:relative; width:100%">
<div style="position:absolute; top:10; right:20; text-align:center; font-weight:bold; font-size:18px">
Receipt ID:<br/>
<?php echo $receiptid ?>
</div>
<b>
    <center>
        Edison State College<br />
        College Administrative Procedures<br />
        Division of Technology Services<br />
        <br />
        Technology Software Loan Program
    </center>
    <hr />
    <br>
    <br>
    Requestor's Name: </b> <?php echo $row['SPRIDEN_FIRST_NAME']." ".$row['SPRIDEN_LAST_NAME'] ?><br><br>
<b>Phone or Extension Number: </b><?php echo $_POST['number'] ?><br><br>
<b>E-Mail Address: </b><?php echo $row['GOBTPAC_EXTERNAL_USER']."@edison.edu" ?><br><br>
<b>Department/Division: </b><?php echo $_POST['department'] ?><br><br>
<b>Software Title Checked-Out: </b><?php echo $row23['sDescription'] ?><br /><br />
<b>Software Disc ID: </b><?php echo $row23['iItemID'] ?><br><br><br>
<b>Software Guidlines:<br></b>
&nbsp;&nbsp;&nbsp;1. Do not copy<br>
&nbsp;&nbsp;&nbsp;2. Only install on 1 PC and 1 Laptop<br>
&nbsp;&nbsp;&nbsp;3. Return within 72 hours<br><br><br>
By signing below, I certify that the software indicated above was checked-out/checked-in as indicated and hereby agree to abide by the terms stated in the Technology Services Division Software Loan Program Procedue and will provide proper care according to the guidlines.  I understand that the department of the signed employee is assuming financial responsibility for the software.<br><br><br>
<table>
    <tr>
        <td>
            <b>CHECK-OUT:</b><br><br>
            ___________________________<br>
            Date Checked Out<br><br>
            ___________________________<br>
            <?php echo $row['SPRIDEN_FIRST_NAME']." ".$row['SPRIDEN_LAST_NAME'] ?><br><br>
            ___________________________<br>
            <?php echo $USER['sFname']." ".$USER['sLname'] ?> - Tech Center SA
        </td>
        <td width="90">
        </td>
        <td>
            <b>CHECK-IN:</b><br><br>
            ___________________________<br>
            Date Checked In<br><br>
            ___________________________<br>
            Incoming Tech Center SA
        </td>
    </tr>
</table>
</div>
<?php } ?>
<?php } ?>
<?php } ?>
</body>
<script>
    //window.print();
	<?php if($_POST['sType'] != ""){ ?>
	//alert('This item is now on hold.  Print this reciept and place it with the equipment.');
	<?php } ?>
</script>